package graphicView;

import java.awt.Color;
import java.awt.Font;
import java.awt.FontMetrics;
import java.awt.Graphics;

import model.*;

import java.util.Observable;

/**
 * Team EBE - Elite Bombard Elephants
 * 
 * PackageGraphicObject.java is the incomplete implementation of a graphical
 * object representing the class
 * 
 */
public class PackageGraphicObject extends Observable {
	private PackageImpl packageObject;
	private boolean active = false;

	/**
	 * PackageGraphicObject creates the package object
	 * 
	 * @param packageObjectIn
	 *            the package object used for package implementation
	 */
	public PackageGraphicObject(PackageImpl packageObjectIn) {
		this.packageObject = packageObjectIn;
	}

	/**
	 * activate simply activates the package object
	 */
	public void activate() {
		active = true;
	}

	/**
	 * deactivate simply deactivates the package object
	 */
	public void deactivate() {
		active = false;
	}

	/**
	 * isActive determines if a package is active
	 * 
	 * @return active returns a boolean value stating that a package object is active
	 */
	public boolean isActive() {
		return active;
	}

	/**
	 * getModel gets the model and returns the package object
	 * 
	 * @return packageObject returns the package object
	 */
	public PackageImpl getModel() {
		return packageObject;
	}

	/**
	 * getHeight gets the height of the package object and returns that value
	 * 
	 * @return packageObject returns the package object with the height
	 */
	public int getHeight() {
		return packageObject.getHeight();
	}

	/**
	 * getWidth gets the width of the package object and returns that value
	 * 
	 * @return packageObject returns the package object with the width
	 */
	public int getWidth() {
		return packageObject.getWidth();
	}

	/**
	 * setHeight sets the height of the package object
	 * 
	 * @param height
	 *            the value of the height set
	 */
	public void setHeight(int height) {
		packageObject.setHeight(height);
	}

	/**
	 * setWidth sets the width of the package object
	 * 
	 * @param width
	 *            the value of the width set
	 */
	public void setWidth(int width) {
		packageObject.setWidth(width);
	}

	/**
	 * getoX gets the value of the x origin of the package object
	 * 
	 * @return packageObject returns the package object with the x origin
	 */
	public int getoX() {
		return packageObject.getoX();
	}

	/**
	 * setoX sets the value of the x origin of the package object
	 * 
	 * @param oX
	 *            the value of the x origin is set
	 */
	public void setoX(int oX) {
		packageObject.setoX(oX);
	}

	/**
	 * getoY gets the value of the y origin of the package object
	 * 
	 * @return packageObject returns the package object with the y origin
	 */
	public int getoY() {
		return packageObject.getoY();
	}

	/**
	 * setoY sets the value of the y origin of the package object
	 * 
	 * @param oY
	 *            the value of the y origin is set
	 */
	public void setoY(int oY) {
		packageObject.setoY(oY);
	}

	/**
	 * drawPackage draws the packages for the project
	 * 
	 * @param g
	 *            the graphics used to draw the packages
	 */
	public void drawPackage(Graphics g) {
		Font title = new Font("serif", Font.BOLD, 16);
		int oX = packageObject.getoX();
		int oY = packageObject.getoY();
		int height = packageObject.getHeight();
		int width = packageObject.getWidth();

		g.setFont(title);
		FontMetrics metrics = g.getFontMetrics();
		int fontWidth = metrics.stringWidth(packageObject.getName());

		g.setColor(Color.gray);
		g.fillRect(oX, oY, width, height);

		g.fillRect(oX, oY - 20, fontWidth + 3, 20);

		g.setColor(Color.black);
		g.drawRect(oX, oY, width, height);

		g.drawRect(oX, oY - 20, fontWidth + 3, 20);

		g.setColor(Color.black);
		g.drawString(packageObject.getName(), oX + 2, oY - 6);

	}
}
